<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript"
	src="http://maps.google.com/maps/api/js?libraries=places&sensor=true"></script>

<script>
	var map;
	var service;
	var infowindow;
	var request;
	function initialize() {
		var pyrmont = new google.maps.LatLng(23.492, 111.315);

		map = new google.maps.Map(document.getElementById('map'), {
			mapTypeId : google.maps.MapTypeId.ROADMAP,
			center : pyrmont,
			zoom : 14
		});
		
		

	}
	
	function refreshFun(str){
		
		
		google.maps.event.addListener(map, 'bounds_changed', refresh(str));
	}

	function refresh(str) {
		hidesearchPointMarker();
		request = {
			location : map.getCenter(),
			radius : '100',
			query : str//restaurant,store,travel,ATM,filling station,Bus station,toilet,MALL,bank
		};

		service = new google.maps.places.PlacesService(map);
		service.textSearch(request, callback);

	}

	var searchPoints = [];
	function callback(results, status) {
		if (results == null) {
			//alert("");
		}
		if (status == google.maps.places.PlacesServiceStatus.OK) {
			if (searchPoints != null) {
				hidesearchPointMarker();
			}
			var temp = results.length;
			if (temp > 15) {
				temp = 15;
			} else {
				temp = results.length;
			}

			for ( var i = 0; i < temp; i++) {
				createMarker(results[i]);
			}
		} else if (status == google.maps.places.PlacesServiceStatus.INVALID_REQUEST) {

			//alert("璇锋眰鏃犳晥");
		} else if (status == google.maps.places.PlacesServiceStatus.OVER_QUERY_LIMIT) {
			//alert("缃戦〉宸茶秴鍑哄叾璇锋眰閰嶉");

		} else if (status == google.maps.places.PlacesServiceStatus.REQUEST_DENIED) {
			//alert("缃戦〉宸茬姝娇鐢ㄥ湴鏂逛俊鎭湇鍔°�");

		} else if (status == google.maps.places.PlacesServiceStatus.ZERO_RESULTS_RESULTS) {
			//alert("鎵句笉鍒板叧浜庢璇锋眰鐨勪换浣曠粨鏋�);

		} else if (status == google.maps.places.PlacesServiceStatus.ERROR) {
			//alert("杩炴帴 Google 鏈嶅姟鍣ㄦ椂鍑虹幇闂");
		}
	}

	function createMarker(aaa) {
		var marker = new google.maps.Marker({
			position : aaa.geometry.location

		});
		searchPoints.push(marker);
		infowindow = new google.maps.InfoWindow();
		var content = '<strong>' + aaa.name + '</strong><br />';
		content += 'Lat: ' + aaa.geometry.location.lat() + '<br />';
		content += 'Lng: ' + aaa.geometry.location.lng();
		content += "<div onclick=Android.phoneCall(12356444);"+">电话订购 </div>" ;
		
		infowindow.setContent(content);
		// 鏄剧ず绐楀彛
		openMarker(marker, content);
		marker.setMap(map);
	}

	function hidesearchPointMarker() {
		if (searchPoints) {
			for ( var i in searchPoints) {
				searchPoints[i].setMap(null);
			}
			searchPoints = [];

		}
	}

	function openMarker(marker, text) {
		google.maps.event.addListener(marker, 'click', function() {
			infowindow.setContent(text);
			infowindow.open(map, marker);
		});
	}
</script>

</head>

<body onload="initialize();">
	<div id="map" style="height:600px;width:320px;"></div>
	<form id="addressForm">
		<div>
			<input id="address" type="textbox" value="" /> <input type="submit"
				value="ti" />
		</div>
	</form>
</body>

</html>





